<%@page import="java.math.BigDecimal"%>
<%@page import="java.lang.Integer"%>
<%@page import="java.util.Hashtable"%>
<%@page import="java.util.List"%>
<%@page import="com.qmerak.common.DataBaseUtil"%>
<%@page import="com.qmerak.common.SpringUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="../../css/style_01.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="../../js/highcharts.js"></script>
<script type="text/javascript" src="../../js/exporting.js"></script>
<%
	String sql = "select sexual groupname,count(*) num from t_member group by sexual";
	List<Hashtable<String, Object>> datas = DataBaseUtil.query(sql);
	Hashtable<String, Object> table = new Hashtable<String, Object>();
	for (Hashtable<String, Object> data : datas) {
		table.put(String.valueOf(data.get("groupname")),
				data.get("num"));
	}
	double menN=Double.parseDouble(DataBaseUtil.sum(table.get("1")));
	double womenN=Double.parseDouble(DataBaseUtil.sum(table.get("2")));
	double otherN=Double.parseDouble(DataBaseUtil.sum(table.get(""),table.get("null")));
	double menR=new BigDecimal(menN/(menN+womenN+otherN)*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
	double womenR=new BigDecimal(womenN/(menN+womenN+otherN)*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
	double otherR=new BigDecimal(otherN/(menN+womenN+otherN)*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
	System.out.println("统计："+table);
	System.out.println("数字："+menN+";"+womenN+";"+otherN);
	System.out.println(menR+";"+womenR+";"+otherR);
%>
<script type="text/javascript">
var rate_men=<%=String.valueOf(menR)%>;
var rate_women=<%=String.valueOf(womenR)%>;
var rate_other=<%=String.valueOf(otherR)%>;
console.log(rate_men+";"+rate_women+";"+rate_other);


$(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: '男女会员比例图'
        },
        tooltip: {
    	    pointFormat: '{series.name}: <b>{point.percentage}%</b>',
        	percentageDecimals: 1
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    formatter: function() {
                        return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
                    }
                }
            }
        },
        series: [{
            type: 'pie',
            name: '性别',
            data: [
                ['男',rate_men],
                ['其他',rate_other],
                {
                    name: '女',
                    y: rate_women,
                    sliced: true,
                    selected: true
                }
            ]
        }]
    });
});
</script>
</head>
<body class="nr_bg">
	<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>